﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Gola.VN.Scb.Web.Dal.Utilities
{
    class Utility
    {
        public static int GetInt(object obj)
        {
            if (obj != null)
            {
                int result = 0;
                if (int.TryParse(obj.ToString(), out result))
                    return result;
            }

            return 0;
        }

        public static string GetString(object obj)
        {
            if (obj != null)
                return obj.ToString();

            return string.Empty;
        }

        public static double GetDouble(object obj)
        {
            if (obj != null)
            {
                double result = 0;
                if (double.TryParse(obj.ToString(), out result))
                    return result;
            }

            return 0;
        }

        public static DateTime GetDateTime(object obj)
        {
            if (obj != null)
            {
                DateTime result = DateTime.Now;
                if (DateTime.TryParse(obj.ToString(), out result))
                    return result;
            }

            return DateTime.Now;
        }
    }
}
